<template>
  <div>
    <!-- <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb> -->
    <el-card class="box-card">
      <el-input placeholder="请输入订单编号" clearable v-model="search">
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
      <el-table :data="orders"  border style="width: 100%">
           <el-table-column type="expand" label="明细" style="text-align:center">
          <template >
              <el-table border style="margin-left:2%;width: 96%" stripe >
                  <el-table-column prop="username"  label="封面" ></el-table-column>
                  <el-table-column prop="username" label="商品名称" ></el-table-column>
                  <el-table-column prop="email" label="商品重量"> </el-table-column>
                  <el-table-column prop="email" label="商品数量" ></el-table-column>
                  <el-table-column prop="username" label="商品价格(元)" ></el-table-column>
                  <el-table-column prop="email" label="总价(元)"> </el-table-column>
              </el-table>
          </template>
        </el-table-column>
        <el-table-column type="index"  label="序号" width="80"></el-table-column>
        <el-table-column prop="order_number" label="订单编号" ></el-table-column>
        <el-table-column prop="order_price" label="订单价格(元)"> </el-table-column>
        <el-table-column prop="mobile" label="是否付款" >
            <el-button type="danger" size="mini"  disabled>未付款</el-button>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货" ></el-table-column>
        <el-table-column prop="create_time" label="下单时间" ></el-table-column>
        <el-table-column prop="address" label="操作" width="120">
          <el-button type="primary" icon="el-icon-edit" size="small" @click="dialogModifyOrders=true"></el-button>
          <el-button type="warning"  icon="el-icon-location-outline" size="small"></el-button>
        </el-table-column>
      </el-table>
  <div class="block">
     <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="params.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
    </el-card>
         <!-- 修改收货地址 -->
    <el-dialog title="修改收货地址" :visible.sync="dialogModifyOrders">
            <el-form ref="modifyform" :model="dialogorders" :rules="$rules.user" >
                <!-- <el-form-item label="省市区/县" :label-width="formLabelWidth" prop="consignee_city">
                    <el-input v-model="dialogorders.consignee_city" autocomplete="off"  ></el-input>
                </el-form-item> -->
                 <el-form-item label="省市区/县" :label-width="formLabelWidth" prop="consignee_city">
                    <el-select v-model="dialogorders.consignee_city" placeholder="请选择活动区域">
                      <el-option label="区域一" value="shanghai"></el-option>
                      <el-option label="区域二" value="beijing"></el-option>
                    </el-select>
                  </el-form-item>
                <el-form-item label="详细地址" :label-width="formLabelWidth" prop="consignee_addr">
                    <el-input v-model="dialogorders.consignee_addr" autocomplete="off" ></el-input>
                </el-form-item>
            </el-form>
            <template v-slot:footer class="dialog-footer">
                <el-button @click="dialogModifyOrders = false">取 消</el-button>
                <el-button type="primary" @click="ModifyRoles()">确 定</el-button>
            </template>
      </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dialogModifyOrders:false,
      dialogorders:{},
      total:null,
      search: "",
      params:{
        pagenum:1,
        query:'',
        pagesize:10,
      },
      orders:[],
      formLabelWidth:"120px"
    }
  },
  methods: {
      handleSizeChange(val) {
        this.params.pagesize=val
        this.LoadOrders();
      },
      handleCurrentChange(val) {
        this.params.pagenum=val
        this.LoadOrders();
      },
    async  LoadOrders(){
        try {
        let result= await this.$api.getOrders(this.params);
        this.orders=result.goods;
        this.total=result.total;
        this.params.pagenum=result.pagenum
        } catch (error) {
            console.log(error)
        }
      }
  },
  created() {
      this.LoadOrders();
  },
};
</script>
<style lang="less" scoped>
.el-breadcrumb {
  margin-bottom: 20px;
}
.el-input {
  margin-bottom: 10px;
  width: 400px;
  margin-right: 20px;
}
.block{
    margin-top: 50px;
}
.el-button {
    border-radius: 10px;
    
}
</style>